import Vue from 'vue'
import VueRouter from 'vue-router'
// 导入一级路由
import Layout from '@/views/layout'
import Reg from '@/views/reg'
import Login from '@/views/login'
import NotFound from '@/views/404'

// 导入二级路由
import Home from '@/views/layout/home'
import Publish from '@/views/layout/publish'
import Sort from '@/views/layout/sort'
import User from '@/views/layout/user'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        component: Home
      },
      {
        path: 'publish',
        component: Publish
      },
      {
        path: 'sort',
        component: Sort
      },
      {
        path: 'user',
        component: User
      }
    ]
  },
  {
    path: '/reg',
    component: Reg
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '*',
    component: NotFound
  }
]

const router = new VueRouter({
  routes
})

export default router
